package cn.sxt.bus.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import cn.sxt.bus.domain.Provider;
import cn.sxt.bus.mapper.ProviderMapper;
import cn.sxt.bus.service.ProviderService;
import cn.sxt.bus.vo.ProviderVo;
import cn.sxt.sys.utils.DataGridView;

@Service
public class ProviderServiceImpl implements ProviderService{

	@Autowired
	private ProviderMapper providerMapper;

	@Override
	public DataGridView queryAllProvider(ProviderVo providerVo) {
		Page<Object> page = PageHelper.startPage(providerVo.getPage(), providerVo.getLimit());
		List<Provider> list = providerMapper.queryAllProvider(providerVo);
		return new DataGridView(page.getTotal(), list);
	}

	@Override
	public int deleteProviderById(ProviderVo providerVo) {
		// TODO Auto-generated method stub
		return providerMapper.deleteByPrimaryKey(providerVo.getId());
	}

	@Override
	public int addProvider(ProviderVo providerVo) {
		// TODO Auto-generated method stub
		return providerMapper.insert(providerVo);
	}

	@Override
	public int updateProvider(ProviderVo providerVo) {
		// TODO Auto-generated method stub
		return providerMapper.updateByPrimaryKeySelective(providerVo);
	}

	@Override
	public Provider queryProviderById(Integer id) {
		// TODO Auto-generated method stub
		return providerMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<Provider> queryAllproviderServiceForList(ProviderVo providerVo) {
		// TODO Auto-generated method stub
		return providerMapper.queryAllProvider(providerVo);
	}
}
